// MySingleLock.h: interface for the CMySingleLock class.
#if !defined(AFX_MYSINGLELOCK_H__E10A3596_1773_403F_A2E1_E14868BAE6A2__INCLUDED_)
#define AFX_MYSINGLELOCK_H__E10A3596_1773_403F_A2E1_E14868BAE6A2__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <WTypes.h>

class ILockObj
{
public:
	virtual void Lock(void) = 0;
	virtual void Unlock(void) = 0;
};

class CMyCriticalSection : public ILockObj
{
public:
	CMyCriticalSection();
	virtual ~CMyCriticalSection();
public:
	virtual void Lock(void);
	virtual void Unlock(void);
private:
	CRITICAL_SECTION m_CritSec;
};

class CMyMutex : public ILockObj
{
public:
	CMyMutex(const wchar_t *pszName);
	virtual ~CMyMutex();
public:
	virtual void Lock(void);
	virtual void Unlock(void);
	static CMyMutex* CreateNew(const char* pszName = NULL, bool bExistTest = false);
private:
	HANDLE m_hMutex;
};

class CMySingleLock
{
public:
	CMySingleLock(ILockObj *pLock);
	virtual ~CMySingleLock();
private:
	ILockObj *m_lock;
};
#endif // !defined(AFX_MYSINGLELOCK_H__E10A3596_1773_403F_A2E1_E14868BAE6A2__INCLUDED_)
